ihelpuoo.namespace("ihelpuoo.widget.list");

ihelpuoo.widget.list.ListItemView = function(parent,patternName,normalClassName,activeClassName)
{
	this.parent = parent;
	this.view = new ihelpuoo.widget.View(parent.oArena
										,(patternName?
										    patternName
											:
											(null==parent.itemPatternName ? 
												"eve.pattern.list.Item"
												:parent.itemPatternName)
										   )
										);
	this.data = null;
	this.oIcon = null;
	this.oTitle = null;
	this.oCheckbox = null;
	
	this.normalClassName = (normalClassName?normalClassName:"eve_list_item_normal");
	this.activeClassName = (activeClassName?activeClassName:"eve_list_item_active");
}

ihelpuoo.widget.list.ListItemView.prototype
=
{
	draw : function(data,fRender)
	{
		this.data = data;
		if(this.view.isNeverBeDrawn())
		{
			this.view.preparePattern();
			this.oIcon = this.view.getElement("icon");
			this.oTitle = this.view.getElement("title");
			this.oCheckbox = this.view.getElement("checkbox");
			if(isIE)
				this.view.shell.style.width="100%";
		}
		if(fRender)
			fRender(this,data);
		this.view.display();
	}
	
	,
	getId: function()
	{
		return this.data.id;
	}
	
	,
	markSelected: function()
	{
		if(this.oCheckbox)
			if(!this.oCheckbox.disabled)
				this.oCheckbox.checked = true;
	}
	
	,
	unMarkSelected: function()
	{
		if(this.oCheckbox)
			this.oCheckbox.checked = false;
	}
	
	,
	isSelected: function()
	{
		if(this.oCheckbox)
			return this.oCheckbox.checked;
		return false;
	}
	
	,
	disactive: function()
	{
		this.view.shell.className = this.normalClassName;
	}
	
	,
	active: function()
	{
		this.view.shell.className = this.activeClassName;
	}
	
	// <WEBOO:INHERIT extends="ihelpuoo.widget.View">
	,getElement: function(key){return this.view.getElement(key);}
	,isNeverBeDrawn: function(){return this.view.isNeverBeDrawn();}
	,preparePattern: function(){this.view.preparePattern();}
	,display: function(){this.view.display();}
	,hide: function(){this.view.hide();}
	,set: function(key,value){this.view.set(key,value);}
	,getString: function(key,defValue){return this.view.getString(key,defValue);}
	,getInt: function(key,defValue){return this.view.getInt(key,defValue);}
	,getBoolean: function(key,defValue){return this.view.getBoolean(key,defValue);}
	,addEvent: function(key,eventName,fnHandler,bCapture){this.view.addEvent(key,eventName,fnHandler,bCapture);}
	,removeEvent: function(key,eventName,fnHandler,bCapture){this.view.removeEvent(key,eventName,fnHandler,bCapture);}
	// </WEBOO:INHERIT>
	
}